import { Directive, HostListener, Input } from '@angular/core';


// 获取不到图片时使用imgState的路径
@Directive({
    selector: '[imgState]'
})
export class ImgStateDirective {
    @Input() imgState;

    constructor() {
    }

    @HostListener('error', ['$event.target'])
    ImageError(event) {
        if (this.imgState) {
            event.src = this.imgState;
        }
    }
}
